package com.training.java.redbox.struts.web;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.action.ActionForm;

public class SignUpForm extends ActionForm{
	private long customerId;
	private String username;
	private String password;
	private String firstname;
	private String lastname;
	private String address;
	private String city;
	private String state;
	private String zipcode;
	
	public String getFirstname() {
		return firstname;
	}
	public void setFirstname(String firstname) {
		this.firstname = firstname;
	}
	public String getLastname() {
		return lastname;
	}
	public void setLastname(String lastname) {
		this.lastname = lastname;
	}
	public String getAddress() {
		return address;
	}
	public void setAddress(String address) {
		this.address = address;
	}
	public String getCity() {
		return city;
	}
	public void setCity(String city) {
		this.city = city;
	}
	public String getState() {
		return state;
	}
	public void setState(String state) {
		this.state = state;
	}
	public String getZipcode() {
		return zipcode;
	}
	public void setZipcode(String zipcode) {
		this.zipcode = zipcode;
	}
	public long getCustomerId() {
		return customerId;
	}
	
	
	
	public String getUsername() {
		return username;
	}
	public void setUsername(String username) {
		this.username = username;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}

	
	@Override
	public ActionErrors validate(ActionMapping mapping,
			HttpServletRequest request)
	{
		System.out.println("i am in signup form ");
		
		ActionErrors errors = new ActionErrors();
		if (firstname==null || firstname.trim().length()==0)
		{
			errors.add(firstname,new ActionMessage("firstname.required"));
		}
		if(lastname==null || lastname.trim().length()==0)
		{
			errors.add(lastname, new ActionMessage("lastname.required"));
		}
		if(username==null || username.trim().length()==0)
		{
			errors.add(username, new ActionMessage("username.required"));
		}
		if(password==null || password.trim().length()==0)
		{
			errors.add(password, new ActionMessage("password.required"));
		}
		
		System.out.println("i am in sign form at the end");
		return errors;
	}


}
